package c.e.a.b.e.c;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
public abstract class u4<MessageType extends u4<MessageType, BuilderType>, BuilderType extends b<MessageType, BuilderType>> extends l3<MessageType, BuilderType> {
    private static Map<Object, u4<?, ?>> zzd = new ConcurrentHashMap();
    public e7 zzb = e7.f;
    private int zzc = -1;

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public enum e {
        public static final /* synthetic */ int[] a = new int[]{1, 2, 3, 4, 5, 6, 7};

        public static int[] a() {
            return (int[]) a.clone();
        }
    }

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public static final class c implements p4<c> {
        public final /* synthetic */ int compareTo(Object obj) {
            throw new NoSuchMethodError();
        }

        public final boolean f() {
            throw new NoSuchMethodError();
        }

        public final boolean g() {
            throw new NoSuchMethodError();
        }

        public final d6 h(d6 d6Var, e6 e6Var) {
            throw new NoSuchMethodError();
        }

        public final h6 i(h6 h6Var, h6 h6Var2) {
            throw new NoSuchMethodError();
        }

        public final int q() {
            throw new NoSuchMethodError();
        }

        public final r7 r() {
            throw new NoSuchMethodError();
        }

        public final y7 s() {
            throw new NoSuchMethodError();
        }
    }

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public static class f<ContainingType extends e6, Type> extends i4<ContainingType, Type> {
    }

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public static class a<T extends u4<T, ?>> extends p3<T> {
        public a(T t) {
        }
    }

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public static abstract class b<MessageType extends u4<MessageType, BuilderType>, BuilderType extends b<MessageType, BuilderType>> extends n3<MessageType, BuilderType> {
        public final MessageType a;
        public MessageType b;
        public boolean c = false;

        public b(MessageType messageType) {
            this.a = messageType;
            this.b = (u4) messageType.o(4, null, null);
        }

        public /* synthetic */ Object clone() throws CloneNotSupportedException {
            b bVar = (b) this.a.o(5, null, null);
            bVar.h((u4) k());
            return bVar;
        }

        public final /* synthetic */ e6 g() {
            return this.a;
        }

        public final BuilderType h(MessageType messageType) {
            if (this.c) {
                j();
                this.c = false;
            }
            u4 u4Var = this.b;
            p6.c.b(u4Var).h(u4Var, messageType);
            return this;
        }

        public final b i(byte[] bArr, int i, h4 h4Var) throws e5 {
            if (this.c) {
                j();
                this.c = false;
            }
            try {
                p6.c.b(this.b).g(this.b, bArr, 0, i, new s3(h4Var));
                return this;
            } catch (e5 e) {
                throw e;
            } catch (IndexOutOfBoundsException unused) {
                throw e5.a();
            } catch (IOException e2) {
                throw new RuntimeException("Reading from byte array should not throw IOException.", e2);
            }
        }

        public void j() {
            u4 u4Var = (u4) this.b.o(4, null, null);
            p6.c.b(u4Var).h(u4Var, this.b);
            this.b = u4Var;
        }

        public e6 k() {
            if (this.c) {
                return this.b;
            }
            u4 u4Var = this.b;
            p6.c.b(u4Var).d(u4Var);
            this.c = true;
            return this.b;
        }

        public e6 l() {
            u4 u4Var = (u4) k();
            if (u4Var.f()) {
                return u4Var;
            }
            throw new d7();
        }
    }

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public static abstract class d<MessageType extends d<MessageType, BuilderType>, BuilderType> extends u4<MessageType, BuilderType> implements f6 {
        public n4<c> zzc = n4.d;

        public final n4<c> u() {
            n4 n4Var = this.zzc;
            if (n4Var.b) {
                this.zzc = (n4) n4Var.clone();
            }
            return this.zzc;
        }
    }

    public static <T extends u4<?, ?>> T l(Class<T> cls) {
        T t = (u4) zzd.get(cls);
        if (t == null) {
            try {
                Class.forName(cls.getName(), true, cls.getClassLoader());
                t = (u4) zzd.get(cls);
            } catch (ClassNotFoundException e) {
                throw new IllegalStateException("Class initialization cannot fail.", e);
            }
        }
        if (t == null) {
            t = (u4) ((u4) l7.c(cls)).o(6, null, null);
            if (t != null) {
                zzd.put(cls, t);
            } else {
                throw new IllegalStateException();
            }
        }
        return t;
    }

    public static <E> b5<E> m(b5<E> b5Var) {
        int size = b5Var.size();
        return b5Var.a(size == 0 ? 10 : size << 1);
    }

    public static c5 n(c5 c5Var) {
        int i = ((s5) c5Var).c;
        return ((s5) c5Var).a(i == 0 ? 10 : i << 1);
    }

    public static Object p(Method method, Object obj, Object... objArr) {
        try {
            return method.invoke(obj, objArr);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Couldn't use Java reflection to implement protocol message reflection.", e);
        } catch (InvocationTargetException e2) {
            Throwable cause = e2.getCause();
            if (cause instanceof RuntimeException) {
                throw ((RuntimeException) cause);
            } else if (cause instanceof Error) {
                throw ((Error) cause);
            } else {
                throw new RuntimeException("Unexpected exception thrown by generated accessor method.", cause);
            }
        }
    }

    public static <T extends u4<?, ?>> void r(Class<T> cls, T t) {
        zzd.put(cls, t);
    }

    public final int b() {
        if (this.zzc == -1) {
            this.zzc = p6.c.b(this).e(this);
        }
        return this.zzc;
    }

    public final /* synthetic */ d6 c() {
        b bVar = (b) o(5, null, null);
        bVar.h(this);
        return bVar;
    }

    public final /* synthetic */ d6 d() {
        return (b) o(5, null, null);
    }

    public final void e(e4 e4Var) throws IOException {
        s6 b = p6.c.b(this);
        x7 x7Var = e4Var.a;
        if (x7Var == null) {
            x7Var = new g4(e4Var);
        }
        b.f(this, x7Var);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            return p6.c.b(this).c(this, (u4) obj);
        }
        return false;
    }

    public final boolean f() {
        byte byteValue = ((Byte) o(1, null, null)).byteValue();
        if (byteValue == (byte) 1) {
            return true;
        }
        if (byteValue == (byte) 0) {
            return false;
        }
        boolean b = p6.c.b(this).b(this);
        o(2, b ? this : null, null);
        return b;
    }

    public final /* synthetic */ e6 g() {
        return (u4) o(6, null, null);
    }

    public int hashCode() {
        int i = this.zza;
        if (i != 0) {
            return i;
        }
        i = p6.c.b(this).a(this);
        this.zza = i;
        return i;
    }

    public final int j() {
        return this.zzc;
    }

    public final void k(int i) {
        this.zzc = i;
    }

    public abstract Object o(int i, Object obj, Object obj2);

    public final <MessageType extends u4<MessageType, BuilderType>, BuilderType extends b<MessageType, BuilderType>> BuilderType s() {
        return (b) o(5, null, null);
    }

    public final BuilderType t() {
        b bVar = (b) o(5, null, null);
        bVar.h(this);
        return bVar;
    }

    public String toString() {
        String obj = super.toString();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("# ");
        stringBuilder.append(obj);
        c.e.a.b.b.j.d.D(this, stringBuilder, 0);
        return stringBuilder.toString();
    }
}
